#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QSerialPort>
#include <QChartView>
#include <QChart>
#include <QByteArray>
#include <QTimer>
#include <QDebug>
#include <QMessageBox>
#include <cstdint>
#include <QValueAxis>
#include <QLineSeries>
#include <QSerialPortInfo>

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget* parent = nullptr);
    ~MainWindow();

private slots:
    void on_action_open_serial_triggered();

    void onReadyRead();

    void onErrorOccurred(QSerialPort::SerialPortError error);

    void updateSeries();

    void on_action_close_serial_triggered();

private:
    Ui::MainWindow* ui;
    QSerialPort* serialPort;
    QChart* chart;
    QChartView* chartView;
    QLineSeries* seriesTemperature;
    QLineSeries* seriesHumidity;
    QByteArray serialBuffer;
    QTimer* timer;
    QValueAxis* axisX;
    QValueAxis* axisY;
    int xValue;
};
#endif   // MAINWINDOW_H
